﻿using Dapper;
using System.Data;
using WinFormsMVVM.Models;

namespace WinFormsMVVM.Services
{
    public class UserService : IUserService
    {
        private readonly IDbConnection _dbConnection;

        public UserService(IDbConnection dbConnection)
        {
            _dbConnection = dbConnection;
        }

        public User? GetUserByUsername(string username)
        {
            string sql = "SELECT * FROM Users WHERE Username = @Username";
            return _dbConnection.QuerySingleOrDefault<User>(sql, new { Username = username });
        }
    }
}